﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using qltscd.Helper;
using CrystalDecisions.Shared;
using CrystalDecisions.CrystalReports.Engine;



namespace qltscd.WebFormShowReport
{
    public partial class ShowRpt : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                Reports.SoTheoDoiQuanLyThietBi so = new Reports.SoTheoDoiQuanLyThietBi();
                TableLogOnInfo info;
                info = so.Database.Tables[0].LogOnInfo;
                info.ConnectionInfo.ServerName = "johnny\\sqlexpress";
                info.ConnectionInfo.DatabaseName = "DuLieuQuanLyThietBi";
                info.ConnectionInfo.UserID = "huynh";
                info.ConnectionInfo.Password = "1234567890";
                CrystalReportViewer1.ReportSource = so;



                //bool flag = true;
                //string srtrptname = Request.QueryString["namerpt"];
                //string tendonvi = SessionHelper.DonViQuanLy.ToString();
                //if (string.IsNullOrEmpty(srtrptname))
                //{
                //    flag = false;
                //}
                //if (flag)
                //{
                //    ////ReportDocument rptD = new ReportDocument();
                //    ////string strpath = Server.MapPath("~/") + "Reports//" + srtrptname;
                //    ////TableLogOnInfos rptinfos = new TableLogOnInfos();
                //    ////TableLogOnInfo rptinfo = new TableLogOnInfo();
                //    ////ConnectionInfo rptcon = new ConnectionInfo();
                //    ////Tables rpttables;
                //    ////rptD.Load(strpath);

                //    ////rptcon.ServerName = @"johnny-pc\sqlexpress";
                //    ////rptcon.DatabaseName = "DuLieuQuanLyThietBi";
                //    ////rptcon.UserID = "huynh";
                //    ////rptcon.Password = "1234567890";

                //    ////rpttables = rptD.Database.Tables;
                //    ////foreach (CrystalDecisions.CrystalReports.Engine.Table rpttable in rpttables)
                //    ////{
                //    ////    rptinfo = rpttable.LogOnInfo;
                //    ////    rptinfo.ConnectionInfo = rptcon;
                //    ////    rpttable.ApplyLogOnInfo(rptinfo);
                //    ////}

                //    ////if (!string.IsNullOrEmpty(tendonvi))
                //    ////{
                //    ////    rptD.SetParameterValue("paraTenDonVi",tendonvi);

                //    ////}
                //    ////CrystalReportViewer1.ReportSource = rptD;
                //    ////Session["NameRpt"]="";
                //    ////Session["TenDonVi"] = "";
                //}
                //else
                //{
                //    Response.Write("<H2>Không tạo được báo cáo</H2>");
                //}


            }
            catch (Exception ex)
            {

                Response.Write(ex.ToString());
            }
        }
    }
}